package com.skyc.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.skyc.entity.Admin;
import com.skyc.service.AdminService;
import com.skyc.service.impl.AdminServiceImpl;

/**
 * Servlet implementation class AServlet
 */
@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest req, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(req, response);

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		response.setCharacterEncoding("utf-8");
		String name = request.getParameter("uname");
		String pwd = request.getParameter("upwd");
		System.out.println(name+pwd);
		AdminService as=new AdminServiceImpl();
		boolean flag=as.login(name,pwd);
		if(flag) {
			response.sendRedirect("AdminsellerorderServlet?op=page&page=1");	
		}else {
			response.sendRedirect("Admin_login.jsp");	
		}
		
	}

}
